package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.system.dos.MessageTemplateDO;
import com.enation.app.javashop.model.system.enums.MessageCodeEnum;
import com.enation.app.javashop.model.system.enums.WechatMsgTemplateTypeEnum;
import com.enation.app.javashop.service.system.MessageTemplateManager;
import com.enation.app.javashop.service.system.WechatMsgTemplateManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 信息模板
 * @date 2018/8/10 9:13
 * @since v7.0.0
 */
@RestController
@RequestMapping("/client")
@ApiIgnore
public class MessageTemplateClientController {


    @Autowired
    private MessageTemplateManager messageTemplateManager;

    @Autowired
    private WechatMsgTemplateManager wechatMsgTemplateManager;

    @GetMapping("/message-template")
    public MessageTemplateDO getModel(@RequestParam("message_code_enum") MessageCodeEnum messageCodeEnum) {
        return messageTemplateManager.getModel(messageCodeEnum);
    }

    @RequestMapping(value = "/message/wechat/send",method = RequestMethod.POST)
    public void sendWechatMsg(@RequestParam("member_id")Long memberId, @RequestParam("message_type")WechatMsgTemplateTypeEnum messageType, @RequestBody List<Object> keywords) {

        wechatMsgTemplateManager.send(memberId, messageType, keywords);
    }
}
